<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
<form action="list" method="get">
    <p>返回日期：<input type="text" name="returnDate"/>
        <input type="submit" value="查询">&nbsp;&nbsp;&nbsp;
        <input type="button" onclick="add()" value="新增">
    </p>
</form>
<table border="1">
    <tr>
        <td>姓名</td>
        <td>身份证</td>
        <td>电话</td>
        <td>出发城市</td>
        <td>返乡日期</td>
        <td>是否访谈</td>
        <td>创建日期</td>
        <td>操作</td>
    </tr>

    <tr th:each="returnPerson : *{list}">
        <td th:text="${returnPerson.personName}"></td>
        <td th:text="${returnPerson.personId}"></td>
        <td th:text="${returnPerson.personPhone}"></td>
        <td th:text="${returnPerson.sendCity}"></td>
        <td th:text="${#dates.format(returnPerson.returnDate,'yyyy-MM-dd HH:mm:ss')}"></td>
        <td th:text="${returnPerson.interviewStatus}"></td>
        <td th:text="${#dates.format(returnPerson.createDate,'yyyy-MM-dd HH:mm:ss')}"></td>


        <td>
            <a th:href="@{/update(id=${returnPerson.id})}">修改</a>
            <a href="JavaScript:void(0)" th:onclick="'del('+${returnPerson.id}+')'">删除</a>
        </td>
    </tr>
</table>

<p>
    <a th:href="@{/list(pageNo=1)}">首页</a>
    <a th:href="@{/list(pageNo=${pageNo-1})}">上一页</a>
    <a th:href="@{/list(pageNo=${pageNo+1})}">下一页</a>
    <a th:href="@{/list(pageNo=${totalPages})}">尾页</a>
    &nbsp;&nbsp;
    第<input type="text" id="pageNo" name="pageNo" th:value="${pageNo}" style="width: 20px"/>页，
    共<span th:text="${totalPages}"></span>页，
    总<span th:text="${totalCount}"></span>条
    <a href="JavaScript:void(0)" onclick="gotoPage()">跳转</a>
</p>

<script>
    function add() {
        location.href = 'add';
    }

    function del(id){
        if(confirm("确定删除？")){
            location.href = "delete/" + id;
        }
    }

    function gotoPage() {
        // 获取用户输入的页码
        var page = document.getElementById("pageNo").value;

        // 进行跳转，这里使用了一个假设的URL和页码参数，你需要替换为实际的URL和参数
        window.location.href = "/list?pageNo=" + page;
    }
</script>
</body>
</html>